package com.example.taobaounion.ui.activity;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.RelativeLayout;

import com.example.taobaounion.R;
import com.example.taobaounion.ui.custom.TextFlowLayout;
import com.example.taobaounion.utils.LogUtils;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class TextActivity extends Activity {

    @BindView(R.id.test_navigation_bar)
    public RadioGroup navigation_bar;

    @BindView(R.id.test_flow_text)
    public TextFlowLayout flow_text;

    @BindView(R.id.edit_test)
    public EditText edit_test;

    @BindView(R.id.edit_test2)
    public EditText edit_test2;

    @BindView(R.id.button)
    public Button button;

    @BindView(R.id.relate)
    public RelativeLayout relate;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_text);
        ButterKnife.bind(this);

        initListener();
        List<String> testList=new ArrayList<>();
        testList.add("电脑");
        testList.add("机械键盘");
        testList.add("运动鞋");
        testList.add("滑板鞋");
        testList.add("阳光沙滩");
        testList.add("android编程");
        testList.add("javaWeb后台");
        testList.add("去哪里儿旅行");
        testList.add("Android自定义控件");
        flow_text.setTextList(testList);
        flow_text.setOnFlowTextItemClickListener(new TextFlowLayout.OnFlowTextItemClickListener() {
            @Override
            public void onFlowItemClick(String text) {
                LogUtils.d(TextActivity.this,"click text --->"+text);
            }
        });
    }

    private void initListener() {
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //此时焦点会跳到edit_test2
                edit_test2.setText("resss");
                relate.setFocusable(true);
                relate.requestFocus();
            }
        });
        navigation_bar.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId){
                    case R.id.test_home:
                        LogUtils.d(TextActivity.class,"首页");
                        break;
                    case R.id.test_red_packet:
                        LogUtils.d(TextActivity.class,"特惠");
                        break;
                    case R.id.test_select:
                        LogUtils.d(TextActivity.class,"精选");
                        break;
                    case R.id.test_search:
                        LogUtils.d(TextActivity.class,"搜索");
                        break;
                }
            }
        });
    }
}